
package pl.niemar22.unitests;

import static org.junit.Assert.assertEquals;

import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;

public abstract class Page {
    
	   public String baseUrl = "http://demo.bananascrum.com/login";
	   
	   protected final WebDriver driver;
	   
	   protected final WebDriverWait wait;
	   
	   public Page(WebDriver driver) {
	       this.driver = driver;
	       wait = new WebDriverWait(driver, 10);
	   }
		
		
		
		
		
   public void assertText(String text, By by) {
       assertEquals(text, driver.findElement(by).getText());
   }
   
   public void insertText(By by, String text) {
       driver.findElement(by).sendKeys(text);
   }

   public void clear(By by) {
       driver.findElement(by).clear();
   }
   
   public void click(By by) {
       driver.findElement(by).click();
   }
  
   public boolean isElementPresent(By by) {
       try {
           driver.findElement(by);
           return true;
       } catch (NoSuchElementException e) {
           return false;
       }
   }
}